home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 5.7 KB | 156 lines | [TEXT/MPS ] |
- // UClipboardMgr.h
- // Copyright © 1984-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UCLIPBOARDMGR__
- #define __UCLIPBOARDMGR__
-
- // MacApp
-
- #ifndef __UBEHAVIOR__
- #include "UBehavior.h"
- #endif
-
- // Toolbox
-
- #ifndef __SCRAP__
- #include <Scrap.h>
- #endif
-
- //----------------------------------------------------------------------------------------
- // Forward and external class declarations.
- //----------------------------------------------------------------------------------------
-
- class TCommandHandler;
- class TView;
- class TWindow;
-
-
- //----------------------------------------------------------------------------------------
- // TClipboardMgr: This object is responsible for interaction with the scrap manager.
- //----------------------------------------------------------------------------------------
-
- const IDType kClipboardManager = 'clip'; // The behavior identifier
-
- class TClipboardMgr : public TBehavior
- {
- MA_DECLARE_CLASS;
-
- public:
- //------------------------------------------------------------------------------------
- // Initialize, I<Method>.
- //------------------------------------------------------------------------------------
-
- TClipboardMgr();
- // Constructor
- virtual ~TClipboardMgr();
- // Destructor
-
- void IClipboardMgr();
-
-
- //------------------------------------------------------------------------------------
- // Rest of methods.
- //------------------------------------------------------------------------------------
-
- virtual void Close();
-
- virtual void Launch();
-
- virtual long GetDataToPaste(Handle aDataHandle, ResType& dataType);
- // Returns the number of bytes in the paste data. Will signal Failure if it gets
- // an error.
-
- virtual TWindow* MakeClipboardWindow();
- // Called by to make the clipboard window. ClipView is the view to be initially
- // installed in the clipboard--it is fClipOrphanage.
-
- virtual TView* MakeViewForAlienClipboard();
- // Calls the application's MakeViewForAlienClipboard.If it returns a view then
- // that view is returned to our caller else it returns fClipOrphanage, which is
- // capable of displaying scrap of type TEXT or PICT. Override this to create a
- // view to handle other types of scrap data.
-
- virtual OSErr PutDeskScrapData(ResType aResType, Handle aDataHandle);
- // Call this from your TCommand method 'WriteToDeskScrap' (for a Command which
- // changes the Clipboard) to write out data to the actual Desk Scrap. The return
- // code from the Scrap Manager is returned as the function value -- will be noErr
- // unless something went wrong. This procedure leaves aDataHandle UNLOCKED. Rather
- // than calling this, you can call the ToolBox routine PutScrap yourself
-
- virtual void AboutToLoseControl(Boolean convertClipboard);
-
- virtual void AbsorbScrapStuff();
- // Called to retrieve the current InfoScrap record from low memory. This will be
- // used to determine if the scrap has changed.
-
- virtual void CheckDeskScrap();
- // Checks to see if the desk scrap has changed by calling AbsorbScrapStuff and
- // comparing the current scrap change count with the previous change count. If the
- // scrap has changed, then the current clipboard becomes the undo clipboard and
- // ReadFromDeskScrap is called to read in the new desk scrap.
-
- virtual void CanPaste(ResType aClipType);
- // Call this in your SetUpMenus code to register an ability to paste a particular
- // type of Clipboard data
-
- virtual void DoSetupMenus();
- // Handles the show/hide clipboard command and enabling of paste
-
- virtual void DoMenuCommand(CommandNumber aCommandNumber);
- // Handles the show/hide clipboard command
-
- virtual void ReadFromDeskScrap();
- // Called at launch and when the desk scrap changes. Calls
- // MakeViewForAlienClipboard, then ClaimClipboard
-
- virtual void RegainControl(Boolean checkClipboard);
- // Called when switching in or when leaving a desk accessory
-
- virtual void SetClipView(TView* clipView, TCommandHandler* itsContext);
- // Installs the given view into the clipboard window.
-
-
- //------------------------------------------------------------------------------------
- // data members
- //------------------------------------------------------------------------------------
- public:
-
- ScrapStuff fOldScrapStuff; // the last ScrapStuff record used in
- // tracking the scrap
-
- ScrapStuff fNewScrapStuff; // the current ScrapStuff record used in
- // tracking the scrap
-
- TView* fClipOrphanage; // A view to represent the Clipboard when
- // the application can't
-
- TView* fClipView; // The view currently installed in the
- // Clipboard
-
- TCommandHandler* fClipContext; // The context of the command which created the
- // current clipboard view.
-
- TWindow* fClipWindow; // The window holding the Clipboard
- // display
-
- ResType fPrefClipType;
-
- Boolean fGotClipType; // True if we can paste the data in the
- // clipboard
-
- Boolean fClipWrittenToDeskScrap; // True if the clipboard view has been
- // written to the desk scrap
- };
-
-
- //----------------------------------------------------------------------------------------
- // Definitions for externally available variables and functions.
- //----------------------------------------------------------------------------------------
-
- extern TClipboardMgr* gClipboardMgr;
-
- extern void InitUClipboardMgr();
- // called to initialize the clipboard manager
-
- #endif // __UCLIPBOARDMGR__
-